package com.dhcc.mybatis.service.user.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.dhcc.mybatis.dto.user.UserDto;
import com.dhcc.mybatis.entity.user.User;
import com.dhcc.mybatis.mapper.user.StudentMapper;
import com.dhcc.mybatis.mapper.user.UserMapper;
import com.dhcc.mybatis.service.user.UserService;

 /**
 * <p>描述：用户信息Service实现类</p>
 * <p>公司：东华医为科技有限公司</p>
 * <p>版权：dhcc-2019</p>
 * @author liuyg
 * @since 2019-12-25
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
	
	@Autowired
	private StudentMapper studentMapper;

    @Override
    public Page<User> list(UserDto dto) {
        QueryWrapper<User> qw = new QueryWrapper<User>();
        if (null == dto.getPage()) {
			dto.setPage(new Page<>());
		}

        return (Page<User>)baseMapper.selectPage(dto.getPage(), qw);
    }

	@Override
	public User getUserById(UserDto dto) {
		return baseMapper.getUserById(dto.getUser().getUserId());
	}

	@Override
	public void saveUserStudent(UserDto dto) {
//		studentMapper.deleteById("0000");
		baseMapper.insert(dto.getUser());
//		dto.getUsers().get(0);
//		studentMapper.insert(dto.getStudent());
	}
}
